package com.chandra.pos.order.service;

import com.chandra.pos.order.dao.IOrderDAO;
import com.chandra.pos.order.dao.entity.Order;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;

/**
 * 
 * Order Service
 * 
 * @author onlinetechvision.com
 * @since 25 Mar 2012
 * @version 1.0.0
 *
 */
@Transactional(readOnly = true)
@Named
public class OrderService implements IOrderService {

	// OrderDAO is injected...
    @Inject
    IOrderDAO orderDAO;
	
	/**
	 * Add Order
	 * 
	 * @param  Order order
	 */
	@Transactional(readOnly = false)
	@Override
	public void addOrder(Order order) {
        orderDAO.addOrder(order);
	}

	/**
	 * Delete Order
	 * 
	 * @param  order order
	 */
	@Transactional(readOnly = false)
	@Override
	public void deleteOrder(Order order) {
        orderDAO.deleteOrder(order);
	}
	
	/**
	 * Update Order
	 * 
	 * @param  Order order
	 */
	@Transactional(readOnly = false)
	@Override
	public void updateOrder(Order order) {
        orderDAO.updateOrder(order);
	}
	
	/**
	 * Get Order
	 * 
	 * @param  int Order Id
	 */
	@Override
	public Order getOrderById(Long id) {
		return orderDAO.getOrderById(id);
	}

	/**
	 * Get Order List
	 * 
	 */
	@Override
	public Page getOrders(PageRequest posPagination) {
		return orderDAO.getOrders(posPagination);
	}

    @Override
    public List<Order> searchOrders(String query) {
        return orderDAO.searchOrders(query);  //To change body of implemented methods use File | Settings | File Templates.
    }




}
